package app.sys.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import app.sys.mapper.DeptMapper;
import app.sys.data.entity.Dept;
import app.sys.model.ResponseObj;
import app.sys.service.DeptService;
import io.github.yedaxia.apidocs.ApiDoc;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 部门管理controller
 */
@ApiDoc
@RestController
@RequestMapping("/sys/dept")
public class DeptController extends BaseRestController<DeptService, DeptMapper, Dept,Long>{
    @Override
    protected QueryWrapper queryWrapper(QueryWrapper<Dept> wrapper) {
        wrapper.orderByDesc("create_time");
        return super.queryWrapper(wrapper);
    }

    /**
     * 返回列表
     *
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @Override
    public ResponseObj<List<Dept>> list(Dept model) throws Exception {
        return super.list(model);
    }

    /**
     * 分页查询
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    @Override
    public ResponseObj<Page<Dept>> listPage(Page<Dept> page, Dept model) throws Exception {
        return super.listPage(page, model);
    }
    /**
     * 查询详情
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    @Override
    public ResponseObj<Dept> detail(Long id) throws Exception {
        return super.detail(id);
    }
    /**
     * 新增
     *
     * @param object
     * @return
     */
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    @Override
    public ResponseObj<Boolean> insert(Dept object) throws Exception {
        return super.insert(object);
    }

    /**
     * 修改
     * @param object
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @Override
    public ResponseObj<Boolean> update(Dept object) throws Exception {
        return super.update(object);
    }
}
